package com.grades.springboot.service.impl;

import com.grades.springboot.entity.Result;
import com.grades.springboot.service.UserInfoService;
import com.grades.springboot.util.JwtUtil;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Override
    public Result<?> getInfo(HttpServletRequest request) {
        String token = request.getHeader("Authorization");
        Map<String,Object> claims = JwtUtil.parseToken(token);
//        String userType = (String) claims.get("userType");
//        String name = (String) claims.get("name");
//        String id = (String) claims.get("id");
        return Result.success(claims);
    }
}
